#include "animation.h"	

#include <QDebug>

Animation::Animation(int joint, float start, float stop, int priority)
{
	currentVal = start;
	startVal = start;
	stopVal = stop;
	priorityVal = priority;
	jointVal = joint;
	
// 	qDebug()<<"New Animation: joint="<<jointVal<<"startVal="<<startVal<<"stopVal"<<stopVal<<"priority"<<priorityVal;
}

void Animation::start()	//rewind to start
{
	currentVal = startVal;
	emit ticked(currentVal);
}

void Animation::end()	//forward to end
{
	currentVal = stopVal;
	emit ticked(currentVal);
}

void Animation::setValue(float value)
{
	currentVal = value;
}

void Animation::tick(float increment)	//update
{
	currentVal += increment;
	
	if (currentVal >= stopVal)
		currentVal = stopVal;
	
	emit ticked(currentVal);
}
	
float Animation::currentValue()
{
	return currentVal;
}

float Animation::startValue()
{
	return startVal;
}

float Animation::stopValue()
{
	return stopVal;
}

int Animation::jointNumber()
{
	return jointVal;
}

int Animation::priority()
{
	return priorityVal;
}

bool Animation::atEnd()
{
	if (currentVal >= stopVal)
		return true;
	else
		return false;
}
